$OpenBSD: patch-Modules_FindJNI_cmake,v 1.16 2015/06/24 06:39:03 dcoppa Exp $
--- Modules/FindJNI.cmake.orig	Mon Jun  1 17:56:08 2015
+++ Modules/FindJNI.cmake	Wed Jun 24 07:52:23 2015
@@ -35,6 +35,8 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+set(MODJAVA_VER $ENV{MODJAVA_VER})
+
 # Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var}
 macro(java_append_library_directories _var)
     # Determine java arch-specific library subdir
@@ -76,8 +78,10 @@ macro(java_append_library_directories _var)
 
     # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
     # system is non-Linux (where the code above has not been well tested)
-    if(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux"))
-        list(APPEND _java_libarch "i386" "amd64" "ppc")
+    if(NOT MODJAVA_VER)
+      if(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux"))
+          list(APPEND _java_libarch "i386" "amd64" "ppc")
+      endif()
     endif()
 
     # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
@@ -109,51 +113,66 @@ if(_JAVA_HOME_EXPLICIT)
   set(CMAKE_FIND_FRAMEWORK NEVER)
 endif()
 
-set(JAVA_AWT_LIBRARY_DIRECTORIES)
-if(_JAVA_HOME)
+if(MODJAVA_VER)
+  set(JAVA_AWT_LIBRARY_DIRECTORIES)
+  if(MODJAVA_VER MATCHES "^1\\.8\\+?$")
+    JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+      ${LOCALBASE}/jdk-1.8.0/jre/lib/{libarch}
+      ${LOCALBASE}/jre-1.8.0/lib/{libarch}
+      )
+  else()
+    JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+      ${LOCALBASE}/jdk-1.7.0/jre/lib/{libarch}
+      ${LOCALBASE}/jre-1.7.0/lib/{libarch}
+      )
+  endif()
+else(MODJAVA_VER)
+  set(JAVA_AWT_LIBRARY_DIRECTORIES)
+  if(_JAVA_HOME)
+    JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+      ${_JAVA_HOME}/jre/lib/{libarch}
+      ${_JAVA_HOME}/jre/lib
+      ${_JAVA_HOME}/lib/{libarch}
+      ${_JAVA_HOME}/lib
+      ${_JAVA_HOME}
+      )
+  endif()
+  get_filename_component(java_install_version
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
+
+  list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
+    )
   JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
-    ${_JAVA_HOME}/jre/lib/{libarch}
-    ${_JAVA_HOME}/jre/lib
-    ${_JAVA_HOME}/lib/{libarch}
-    ${_JAVA_HOME}/lib
-    ${_JAVA_HOME}
+    /usr/lib
+    /usr/local/lib
+    /usr/lib/jvm/java/lib
+    /usr/lib/java/jre/lib/{libarch}
+    /usr/lib/jvm/jre/lib/{libarch}
+    /usr/local/lib/java/jre/lib/{libarch}
+    /usr/local/share/java/jre/lib/{libarch}
+    /usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
+    /usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
+    /opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
+    /usr/lib/jvm/java-6-sun/jre/lib/{libarch}
+    /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
+    /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch}       # can this one be removed according to #8821 ? Alex
+    /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
+    /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch}        # fedora
+    # Debian specific paths for default JVM
+    /usr/lib/jvm/default-java/jre/lib/{libarch}
+    /usr/lib/jvm/default-java/jre/lib
+    /usr/lib/jvm/default-java/lib
+    # OpenBSD specific paths for default JVM
+    ${LOCALBASE}/jdk-1.7.0/jre/lib/{libarch}
+    ${LOCALBASE}/jre-1.7.0/lib/{libarch}
+    ${LOCALBASE}/jdk-1.8.0/jre/lib/{libarch}
+    ${LOCALBASE}/jre-1.8.0/lib/{libarch}
     )
-endif()
-get_filename_component(java_install_version
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
+endif(MODJAVA_VER)
 
-list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
-  )
-JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
-  /usr/lib
-  /usr/local/lib
-  /usr/lib/jvm/java/lib
-  /usr/lib/java/jre/lib/{libarch}
-  /usr/lib/jvm/jre/lib/{libarch}
-  /usr/local/lib/java/jre/lib/{libarch}
-  /usr/local/share/java/jre/lib/{libarch}
-  /usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
-  /usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
-  /opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
-  /usr/lib/jvm/java-6-sun/jre/lib/{libarch}
-  /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
-  /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch}       # can this one be removed according to #8821 ? Alex
-  /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
-  /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch}        # fedora
-  # Debian specific paths for default JVM
-  /usr/lib/jvm/default-java/jre/lib/{libarch}
-  /usr/lib/jvm/default-java/jre/lib
-  /usr/lib/jvm/default-java/lib
-  # OpenBSD specific paths for default JVM
-  /usr/local/jdk-1.7.0/jre/lib/{libarch}
-  /usr/local/jre-1.7.0/lib/{libarch}
-  /usr/local/jdk-1.6.0/jre/lib/{libarch}
-  /usr/local/jre-1.6.0/lib/{libarch}
-  )
-
 set(JAVA_JVM_LIBRARY_DIRECTORIES)
 foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
   list(APPEND JAVA_JVM_LIBRARY_DIRECTORIES
@@ -163,33 +182,46 @@ foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
     )
 endforeach()
 
-set(JAVA_AWT_INCLUDE_DIRECTORIES)
-if(_JAVA_HOME)
-  list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES ${_JAVA_HOME}/include)
-endif()
-list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
-  "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
-  /usr/include
-  /usr/local/include
-  /usr/lib/java/include
-  /usr/local/lib/java/include
-  /usr/lib/jvm/java/include
-  /usr/lib/jvm/java-6-sun/include
-  /usr/lib/jvm/java-1.5.0-sun/include
-  /usr/lib/jvm/java-6-sun-1.6.0.00/include       # can this one be removed according to #8821 ? Alex
-  /usr/lib/jvm/java-6-openjdk/include
-  /usr/local/share/java/include
-  /usr/lib/j2sdk1.4-sun/include
-  /usr/lib/j2sdk1.5-sun/include
-  /opt/sun-jdk-1.5.0.04/include
-  # Debian specific path for default JVM
-  /usr/lib/jvm/default-java/include
-  # OpenBSD specific path for default JVM
-  /usr/local/jdk-1.7.0/include
-  /usr/local/jdk-1.6.0/include
-  )
+if(MODJAVA_VER)
+  set(JAVA_AWT_INCLUDE_DIRECTORIES)
+  if(MODJAVA_VER MATCHES "^1\\.8\\+?$")
+    list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
+      ${LOCALBASE}/jdk-1.8.0/include
+      )
+  else()
+    list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
+      ${LOCALBASE}/jdk-1.7.0/include
+      )
+  endif()
+else(MODJAVA_VER)
+  set(JAVA_AWT_INCLUDE_DIRECTORIES)
+  if(_JAVA_HOME)
+    list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES ${_JAVA_HOME}/include)
+  endif()
+  list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
+    /usr/include
+    /usr/local/include
+    /usr/lib/java/include
+    /usr/local/lib/java/include
+    /usr/lib/jvm/java/include
+    /usr/lib/jvm/java-6-sun/include
+    /usr/lib/jvm/java-1.5.0-sun/include
+    /usr/lib/jvm/java-6-sun-1.6.0.00/include       # can this one be removed according to #8821 ? Alex
+    /usr/lib/jvm/java-6-openjdk/include
+    /usr/local/share/java/include
+    /usr/lib/j2sdk1.4-sun/include
+    /usr/lib/j2sdk1.5-sun/include
+    /opt/sun-jdk-1.5.0.04/include
+    # Debian specific path for default JVM
+    /usr/lib/jvm/default-java/include
+    # OpenBSD specific path for default JVM
+    ${LOCALBASE}/jdk-1.7.0/include
+    ${LOCALBASE}/jdk-1.8.0/include
+    )
+endif(MODJAVA_VER)
 
 foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
   get_filename_component(jpath "${JAVA_PROG}" PATH)
